-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minor updates to JDBC caching client #8652
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please rebase
@@ -45,7 +45,7 @@ public JdbcMetadata create(JdbcTransactionHandle transaction) | |||
jdbcClient, | |||
Set.of(), | |||
new SingletonJdbcIdentityCacheMapping(), | |||
new Duration(1, DAYS), true), | |||
new Duration(1, DAYS), true, 10000), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Integer.MAX_VALUE here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is per-transaction cache, and transaction = query in JDBC connectors. Hence, for example, 1d hard-coded eviction time, which is "infinity in practice".
Is there any problem with not capping per-transaction cache with cacheMaximumSize
?
The cacheMaximumSize
will still be applied in @Inject CachingJdbcClient::new
, which is used to configure permanent CachingJdbcClient
(singleton).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
}); | ||
|
||
// cleanup | ||
this.jdbcClient.dropTable(SESSION, first); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redundant this.
?
@ConfigDescription("Maximum number of objects stored in the metadata cache") | ||
public BaseJdbcConfig setCacheMaximumSize(long cacheMaximumSize) | ||
{ | ||
this.cacheMaximumSize = cacheMaximumSize; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we want to reject configuration like
metadata.cache-maximum-size = 100
# metadata.cache-ttl is not set
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that is a good idea. As an admin, it would be nice to know that changing the cache size does not enable the cache unless cache-til
is set.
I added a validation method that validates the cache config to do this.
79e4e02
to
171e39c
Compare
@findepi thanks for having a look. Updated based on your feedback. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments.
What is the motivation for the change? Is it that the cache was unbounded previously and grew very large at times?
plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/CachingJdbcClient.java
Outdated
Show resolved
Hide resolved
plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/DefaultJdbcMetadataFactory.java
Outdated
Show resolved
Hide resolved
plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/CachingJdbcClient.java
Outdated
Show resolved
Hide resolved
@hashhar there are a few motivations for the changes:
|
b1553aa
to
11a9a01
Compare
@@ -45,7 +46,7 @@ public JdbcMetadata create(JdbcTransactionHandle transaction) | |||
jdbcClient, | |||
Set.of(), | |||
new SingletonIdentityCacheMapping(), | |||
new Duration(1, DAYS), true), | |||
new Duration(1, DAYS), true, DEFAULT_METADATA_CACHE_SIZE), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put true, DEFAULT_METADATA_CACHE_SIZE
on separate lines
969a7db
to
69f9006
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM % comment.
{ | ||
if (metadataCacheTtl.equals(CACHING_DISABLED) && cacheMaximumSize != BaseJdbcConfig.DEFAULT_METADATA_CACHE_SIZE) { | ||
throw new IllegalArgumentException( | ||
format("Invalid JDBC metadata caching configuration. No TTL is configured (%s) so metadata caching is disabled and changing the cache size to %s has no effect", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
format("Invalid JDBC metadata caching configuration. No TTL is configured (%s) so metadata caching is disabled and changing the cache size to %s has no effect", | |
format("metadata.cache-ttl must be set to a non-zero value when metadata.cache-maximum-size is set", |
Maybe this? With an exception the actual property names causing issue should be present IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I like your suggestion as it is more concise. I went through a few iterations of this error message. Its hard to come up with a good error message :)
69f9006
to
8ec4c85
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Some minor updates to the JDBC caching client that are useful for cluster admins:
flushCache
to allow invalidating of the cache